package com.five.community.service.impl;

import com.five.community.bean.Person;
import com.five.community.bean.vo.PersonVo;
import com.five.community.mapper.PersonMapper;
import com.five.community.service.PersonService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.security.Permission;
import java.util.List;

@Service
public class PersonServiceImpl implements PersonService {
    @Autowired
    private PersonMapper personMapper;
    @Override
    public List<Person> selectAll() throws Exception {
       return personMapper.selectAll();
    }

    @Override
    public List<PersonVo> selectAllPerson(Integer pageNum,Integer pageSize) throws Exception {
        PageHelper.startPage(pageNum,pageSize);
        return personMapper.selectAllPerson();
    }

    @Override
    public void insert(Person person) throws Exception {
        personMapper.insert(person);
    }

    @Override
    public void deleteById(long id) throws Exception {
        personMapper.deleteById(id);
    }

    @Override
    public Person selectById(long id) throws Exception {
        return personMapper.selectById(id);
    }

    @Override
    public void update(Person person) throws Exception {
        personMapper.update(person);
    }

    @Override
    public List<PersonVo> selectByName(String name) throws Exception {
        return personMapper.selectByName(name);
    }

    @Override
    public List<PersonVo> selectAllPerson() throws Exception {
        return personMapper.selectAllPerson();
    }

    @Override
    public List<PersonVo> selectAllByName(Integer pageNum, Integer pageSize, String name) throws Exception {
        PageHelper.startPage(pageNum,pageSize);
        return personMapper.selectByName(name);
    }


}
